<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>blocklyDemo</title>
<script src="resources/script/blockly/blockly_compressed.js"></script>
<script src="resources/script/blockly/blocks_compressed.js"></script>

<script src="resources/script/blockly/en.js"></script>
<script src="//cdn.bootcss.com/jquery/3.1.1/jquery.js"></script>
<script type="text/javascript" src="resources/script/blockly/math.js"></script>
<script type="text/javascript" src="resources/script/blockly/python_compressed.js"></script>
<style type="text/css">
	html,body{margin: 0px;padding: 0px;height: 100%;width: 100% background-color: #fff;font-family: sans-serif;}
	#run{ position:fixed;right:0;width:100px;height:100px;z-index:999;background:rgba(0,0,0,0.5);line-height:100px; text-align:center;cursor: pointer;}
</style>
<script type="text/javascript" src="resources/script/blockly/myBlockly2.js"></script>
</head>
<body>
	<span id="run" data-toggle="modal" data-target="#myModal">RUN</span>
	<div id="blocklyDiv" style="height: 100%; width: 100%;"></div>
	<xml id="toolbox" style="display: none"> 
		 <category name="逻辑" id="Logic" colour="210">
	     	<block type="controls_if"></block>
	     	<block type="logic_compare"></block>
	     	<block type="logic_operation"></block>
	     	<block type="logic_negate"></block>
	     	<block type='sign'></block>
	     	<block type="math_arithmetic">
		        <value name="A">
		          <shadow type="math_number">
		            <field name="NUM">1</field>
		          </shadow>
		        </value>
		        <value name="B">
		          <shadow type="math_number">
		            <field name="NUM">1</field>
		          </shadow>
		        </value>
      		</block>
	    </category>
	     <category name="数据" colour="120" id="Data">
	    </category>
	     <category name="交易" colour="230" id="Deal">
	     	<block type="controls_if"></block>
	     	<block type="logic_compare"></block>
	    </category>
	    <category name="定义变量" custom="VARIABLE"></category>
	    
	</xml>
	
</body>
<script>
	blockly2.initBlockly2();
	var workspace = Blockly.inject('blocklyDiv', {
		media : 'resources/script/blockly/media/',
		toolbox : document.getElementById('toolbox')
	});
	document.getElementById("run").onclick = function(){
		var code = Blockly.Python.workspaceToCode(workspace);
		console.log(code);
	};
</script>

</html>